package com.wq.gof.designer.command;

/**
 * @Author: wangqiang20995
 * @Date:2019/1/25
 * @Description:
 * @Resource:
 */
public class Invoker implements ICommand{

    private ICommand command;

    public ICommand getCommand() {
        return command;
    }

    public void setCommand(ICommand command) {
        this.command = command;
    }

    @Override
    public void execute() {
        if(this.command == null){
            throw new NullPointerException("empty command");
        }

        command.execute();
    }

    @Override
    public void cancel() {
        if(this.command == null){
            throw new NullPointerException("empty command");
        }

        command.cancel();
    }
}
